Expand ~/$HOME in push input paths - #141
Merged
Merged
Conversation
markpost push '~/vault/**' quoted the glob to stop the shell touching
it, which also stopped the shell expanding the leading ~, so the literal
~ globbed against nothing. Expand a leading ~, $HOME, or ${HOME} in
resolveMarkdownInputs before resolving, so quoted and unquoted inputs
resolve the same target. The unmatched-input report keeps the raw path
the user typed.
Closes #134
Collaborator
Author
Independent code review trailRan the independent reviewer (Opus) on the branch diff over 2 rounds. Round 1 — 4 findings
Round 2 — 6 findings
Reviewer confirmed no Code-Standards violations (small functions, flat control flow with guard clauses, full names, no rule-of-three breach). Final: lint clean, typecheck clean, 715 tests passing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
markpost push '~/vault/**'never matched anything: the user quotes the glob to stop the shell expanding it early, but that also stops the shell expanding the leading~, so a literal~was globbed against the filesystem and matched nothing (the path silently landed inmissing).This expands a leading home reference (
~,$HOME, or${HOME}) inresolveMarkdownInputs(src/libs/files.ts) before resolving each input, so quoted and unquoted inputs resolve to the same target.Decisions
$HOMEexpansion anywhere today (getOutputDirectoryinmarkdown.tsreads the value verbatim). So this adds a small, self-containedexpandHomeDirectoryhelper rather than duplicating anything.~) or a<ref>/…prefix is expanded.~backup/note.mdand$HOMEBREW/note.mdare left literal — they are not home references.path.join. The remainder (including glob metacharacters like**) is spliced onto the home path directly sojoin's normalization can't alter the glob pattern.missingkeeps the raw input. An unmatched~/nope.mdis reported as the user typed it, consistent with this file's "read the way the user typed them" convention;files/skippedcarry the resolved paths. Locked in by a test.~,~/…,$HOME,$HOME/…,${HOME},${HOME}/….Tests
Added a
home directory expansionblock intests/libs/files.test.tscovering:~/…,$HOME/…,${HOME}/…globs matching under home; bare~and$HOMEresolving to the home directory; non-references (~backup,$HOMEBREW) left untouched; and an unmatched home reference reported raw. All 715 tests pass; lint and typecheck clean.Viewable
CLI behavior — run
markpost push '~/vault/**'against a vault under$HOME.Closes #134
Follow-up suggestions
Escape glob metacharacters in the expanded home path— a home directory containing a glob metacharacter ([,*,?, etc.) makes an expanded~/…glob silently match nothing; escape the home-path segment on the glob branch (threading base/remainder throughresolveInput) so such home paths still resolve. (suggested: P4, effort: S, evidence: src/libs/files.ts expandHomeReference/collectFromGlob)